#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

#include <oqs/sha3.h>

#if defined(WINDOWS)
#define UNUSED
#else
#define UNUSED __attribute__((unused))
#endif

/**
* \file sha3_test.h
* \brief <b>SHA3 Known Answer Tests</b> \n
* Uses Known Answer Tests from official sources to verify the
* correct operation of SHA3 digest and SHAKE implementations.
* \author John Underhill
* \date December 28, 2017
*/

/*! \enum SHA3_TEST_STATUS
* The test function result state
*/
enum SHA3_TEST_STATUS {
	SHA3_STATUS_FAILURE = 0, /*!< signals test failure */
	SHA3_STATUS_SUCCESS = 1  /*!< signals test success */
};

/**
* \brief Compares two arrays of 8 bit integers for equivalence
*
* \param a The first byte array for comparison
* \param b The second byte array for comparison
* \param length The number of bytes to compare
*
* \return Returns zero for failure, one if the arrays match
*/
static int are_equal8(const uint8_t *a, const uint8_t *b, size_t length) {
	size_t i;
	int status = SHA3_STATUS_SUCCESS;

	for (i = 0; i < length; ++i) {
		if (a[i] != b[i]) {
			status = SHA3_STATUS_FAILURE;
			break;
		}
	}

	return status;
}

/**
* \brief Set a number of a uint8 array elements to zero
*
* \param a The array to reset
* \param count The number of uint8 integers to clear
*/
static void clear8(uint8_t *a, size_t count) {
	for (size_t i = 0; i < count; ++i) {
		a[i] = 0;
	}
}

/**
* \brief Set a number of a uint64 array elements to zero
*
* \param a The array to reset
* \param count The number of uint64 integers to clear
*/
static void clear64(uint64_t *a, size_t count) {
	for (size_t i = 0; i < count; ++i) {
		a[i] = 0;
	}
}

/**
* \brief Tests the 256 bit version of the keccak message digest for correct operation,
* using selected vectors from the NIST Fips202 and alternative references.
*
* \return Returns 1 for success, 0 for failure
*
* \remarks <b>Test References:</b> \n
* Fips202: <a href="http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf">SHA3-Standard</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-256_Msg0.pdf">SHA256(0)</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-256_1600.pdf">SHA256(1600)</a> \n
* KAT: <a href="https://www.di-mgt.com.au/sha_testvectors.html">SHA256(24, 448)</a>
*/
int sha3_256_kat_test() {
	int status = SHA3_STATUS_SUCCESS;

	uint8_t output[32];

	uint8_t msg0[1] = {0x0};
	uint8_t msg24[3] = {0x61, 0x62, 0x63};
	uint8_t msg448[56] = {
	    0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
	    0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, 0x67, 0x68, 0x69, 0x6A, 0x68, 0x69, 0x6A, 0x6B,
	    0x69, 0x6A, 0x6B, 0x6C, 0x6A, 0x6B, 0x6C, 0x6D, 0x6B, 0x6C, 0x6D, 0x6E, 0x6C, 0x6D, 0x6E, 0x6F,
	    0x6D, 0x6E, 0x6F, 0x70, 0x6E, 0x6F, 0x70, 0x71};
	uint8_t msg1600[200] = {
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,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0x04, 0x5C, 0x17, 0x2D, 0x6B, 0xD3, 0x90, 0xBD,
	    0x85, 0x5F, 0x08, 0x6E, 0x3E, 0x9D, 0x52, 0x5B, 0x46, 0xBF, 0xE2, 0x45, 0x11, 0x43, 0x15, 0x32};
	uint8_t exp448[32] = {
	    0x41, 0xC0, 0xDB, 0xA2, 0xA9, 0xD6, 0x24, 0x08, 0x49, 0x10, 0x03, 0x76, 0xA8, 0x23, 0x5E, 0x2C,
	    0x82, 0xE1, 0xB9, 0x99, 0x8A, 0x99, 0x9E, 0x21, 0xDB, 0x32, 0xDD, 0x97, 0x49, 0x6D, 0x33, 0x76};
	uint8_t exp1600[32] = {
	    0x79, 0xF3, 0x8A, 0xDE, 0xC5, 0xC2, 0x03, 0x07, 0xA9, 0x8E, 0xF7, 0x6E, 0x83, 0x24, 0xAF, 0xBF,
	    0xD4, 0x6C, 0xFD, 0x81, 0xB2, 0x2E, 0x39, 0x73, 0xC6, 0x5F, 0xA1, 0xBD, 0x9D, 0xE3, 0x17, 0x87};

	/* test compact api */

	clear8(output, 32);
	OQS_SHA3_sha3256(output, msg0, 0);

	if (are_equal8(output, exp0, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 32);
	OQS_SHA3_sha3256(output, msg24, 3);

	if (are_equal8(output, exp24, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 32);
	OQS_SHA3_sha3256(output, msg448, 56);

	if (are_equal8(output, exp448, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 32);
	OQS_SHA3_sha3256(output, msg1600, 200);

	if (are_equal8(output, exp1600, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	/* test long-form api */

	uint64_t state[25];
	uint8_t hash[200];

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_256_RATE, msg0, 0, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_256_RATE);

	if (are_equal8(hash, exp0, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_256_RATE, msg24, 3, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_256_RATE);

	if (are_equal8(hash, exp24, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_256_RATE, msg448, 56, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_256_RATE);

	if (are_equal8(hash, exp448, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_256_RATE, msg1600, 200, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_256_RATE);

	if (are_equal8(hash, exp1600, 32) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	return status;
}

/**
* \brief Tests the 512 bit version of the keccak message digest for correct operation,
* using selected vectors from NIST Fips202 and alternative references.
*
* \return Returns 1 for success, 0 for failure
*
* \remarks <b>Test References:</b> \n
* Fips202: <a href="http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf">SHA3-Standard</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-512_Msg0.pdf">SHA512(0)</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-512_1600.pdf">SHA512(1600)</a> \n
* KAT: <a href="https://www.di-mgt.com.au/sha_testvectors.html">SHA512(24, 448)</a>
*/
int sha3_512_kat_test() {
	int status = SHA3_STATUS_SUCCESS;

	uint8_t output[64];

	uint8_t msg0[1] = {0x0};
	uint8_t msg24[3] = {0x61, 0x62, 0x63};
	uint8_t msg448[56] = {
	    0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67,
	    0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, 0x67, 0x68, 0x69, 0x6A, 0x68, 0x69, 0x6A, 0x6B,
	    0x69, 0x6A, 0x6B, 0x6C, 0x6A, 0x6B, 0x6C, 0x6D, 0x6B, 0x6C, 0x6D, 0x6E, 0x6C, 0x6D, 0x6E, 0x6F,
	    0x6D, 0x6E, 0x6F, 0x70, 0x6E, 0x6F, 0x70, 0x71};
	uint8_t msg1600[200] = {
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3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, 0x2C, 0x3A, 0xC5, 0x58,
	    0xF5, 0x00, 0x19, 0x9D, 0x95, 0xB6, 0xD3, 0xE3, 0x01, 0x75, 0x85, 0x86, 0x28, 0x1D, 0xCD, 0x26};
	uint8_t exp24[64] = {
	    0xB7, 0x51, 0x85, 0x0B, 0x1A, 0x57, 0x16, 0x8A, 0x56, 0x93, 0xCD, 0x92, 0x4B, 0x6B, 0x09, 0x6E,
	    0x08, 0xF6, 0x21, 0x82, 0x74, 0x44, 0xF7, 0x0D, 0x88, 0x4F, 0x5D, 0x02, 0x40, 0xD2, 0x71, 0x2E,
	    0x10, 0xE1, 0x16, 0xE9, 0x19, 0x2A, 0xF3, 0xC9, 0x1A, 0x7E, 0xC5, 0x76, 0x47, 0xE3, 0x93, 0x40,
	    0x57, 0x34, 0x0B, 0x4C, 0xF4, 0x08, 0xD5, 0xA5, 0x65, 0x92, 0xF8, 0x27, 0x4E, 0xEC, 0x53, 0xF0};
	uint8_t exp448[64] = {
	    0x04, 0xA3, 0x71, 0xE8, 0x4E, 0xCF, 0xB5, 0xB8, 0xB7, 0x7C, 0xB4, 0x86, 0x10, 0xFC, 0xA8, 0x18,
	    0x2D, 0xD4, 0x57, 0xCE, 0x6F, 0x32, 0x6A, 0x0F, 0xD3, 0xD7, 0xEC, 0x2F, 0x1E, 0x91, 0x63, 0x6D,
	    0xEE, 0x69, 0x1F, 0xBE, 0x0C, 0x98, 0x53, 0x02, 0xBA, 0x1B, 0x0D, 0x8D, 0xC7, 0x8C, 0x08, 0x63,
	    0x46, 0xB5, 0x33, 0xB4, 0x9C, 0x03, 0x0D, 0x99, 0xA2, 0x7D, 0xAF, 0x11, 0x39, 0xD6, 0xE7, 0x5E};
	uint8_t exp1600[64] = {
	    0xE7, 0x6D, 0xFA, 0xD2, 0x20, 0x84, 0xA8, 0xB1, 0x46, 0x7F, 0xCF, 0x2F, 0xFA, 0x58, 0x36, 0x1B,
	    0xEC, 0x76, 0x28, 0xED, 0xF5, 0xF3, 0xFD, 0xC0, 0xE4, 0x80, 0x5D, 0xC4, 0x8C, 0xAE, 0xEC, 0xA8,
	    0x1B, 0x7C, 0x13, 0xC3, 0x0A, 0xDF, 0x52, 0xA3, 0x65, 0x95, 0x84, 0x73, 0x9A, 0x2D, 0xF4, 0x6B,
	    0xE5, 0x89, 0xC5, 0x1C, 0xA1, 0xA4, 0xA8, 0x41, 0x6D, 0xF6, 0x54, 0x5A, 0x1C, 0xE8, 0xBA, 0x00};

	/* test compact api */

	clear8(output, 64);
	OQS_SHA3_sha3512(output, msg0, 0);

	if (are_equal8(output, exp0, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 64);
	OQS_SHA3_sha3512(output, msg24, 3);

	if (are_equal8(output, exp24, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 64);
	OQS_SHA3_sha3512(output, msg448, 56);

	if (are_equal8(output, exp448, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 64);
	OQS_SHA3_sha3512(output, msg1600, 200);

	if (are_equal8(output, exp1600, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	/* test long-form api */

	uint64_t state[25];
	uint8_t hash[200];

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_512_RATE, msg0, 0, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_512_RATE);

	if (are_equal8(hash, exp0, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_512_RATE, msg24, 3, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_512_RATE);

	if (are_equal8(hash, exp24, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_512_RATE, msg448, 56, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_512_RATE);

	if (are_equal8(hash, exp448, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(hash, 200);
	clear64(state, 25);
	OQS_SHA3_keccak_absorb(state, OQS_SHA3_SHA3_512_RATE, msg1600, 200, OQS_SHA3_SHA3_DOMAIN);
	OQS_SHA3_keccak_squeezeblocks(hash, 1, state, OQS_SHA3_SHA3_512_RATE);

	if (are_equal8(hash, exp1600, 64) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	return status;
}

/**
* \brief Tests the 128 bit version of the SHAKE XOF function for correct operation,
* using selected vectors from the NIST reference package.
*
* \return Returns 1 for success, 0 for failure
*
* \remarks <b>Test References:</b> \n
* SP800-185: <a href="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf">SHA-3 Derived Functions</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHAKE128_Msg0.pdf">SHAKE128(0)</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHAKE128_Msg1600.pdf">SHAKE128(1600)</a>
*/
int shake_128_kat_test() {
	int status = SHA3_STATUS_SUCCESS;

	uint8_t output[512];

	uint8_t msg0[1] = {0x0};
	uint8_t msg1600[200] = {
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3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0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3};

	uint8_t exp0[512] = {
	    0x7F, 0x9C, 0x2B, 0xA4, 0xE8, 0x8F, 0x82, 0x7D, 0x61, 0x60, 0x45, 0x50, 0x76, 0x05, 0x85, 0x3E,
	    0xD7, 0x3B, 0x80, 0x93, 0xF6, 0xEF, 0xBC, 0x88, 0xEB, 0x1A, 0x6E, 0xAC, 0xFA, 0x66, 0xEF, 0x26,
	    0x3C, 0xB1, 0xEE, 0xA9, 0x88, 0x00, 0x4B, 0x93, 0x10, 0x3C, 0xFB, 0x0A, 0xEE, 0xFD, 0x2A, 0x68,
	    0x6E, 0x01, 0xFA, 0x4A, 0x58, 0xE8, 0xA3, 0x63, 0x9C, 0xA8, 0xA1, 0xE3, 0xF9, 0xAE, 0x57, 0xE2,
	    0x35, 0xB8, 0xCC, 0x87, 0x3C, 0x23, 0xDC, 0x62, 0xB8, 0xD2, 0x60, 0x16, 0x9A, 0xFA, 0x2F, 0x75,
	    0xAB, 0x91, 0x6A, 0x58, 0xD9, 0x74, 0x91, 0x88, 0x35, 0xD2, 0x5E, 0x6A, 0x43, 0x50, 0x85, 0xB2,
	    0xBA, 0xDF, 0xD6, 0xDF, 0xAA, 0xC3, 0x59, 0xA5, 0xEF, 0xBB, 0x7B, 0xCC, 0x4B, 0x59, 0xD5, 0x38,
	    0xDF, 0x9A, 0x04, 0x30, 0x2E, 0x10, 0xC8, 0xBC, 0x1C, 0xBF, 0x1A, 0x0B, 0x3A, 0x51, 0x20, 0xEA,
	    0x17, 0xCD, 0xA7, 0xCF, 0xAD, 0x76, 0x5F, 0x56, 0x23, 0x47, 0x4D, 0x36, 0x8C, 0xCC, 0xA8, 0xAF,
	    0x00, 0x07, 0xCD, 0x9F, 0x5E, 0x4C, 0x84, 0x9F, 0x16, 0x7A, 0x58, 0x0B, 0x14, 0xAA, 0xBD, 0xEF,
	    0xAE, 0xE7, 0xEE, 0xF4, 0x7C, 0xB0, 0xFC, 0xA9, 0x76, 0x7B, 0xE1, 0xFD, 0xA6, 0x94, 0x19, 0xDF,
	    0xB9, 0x27, 0xE9, 0xDF, 0x07, 0x34, 0x8B, 0x19, 0x66, 0x91, 0xAB, 0xAE, 0xB5, 0x80, 0xB3, 0x2D,
	    0xEF, 0x58, 0x53, 0x8B, 0x8D, 0x23, 0xF8, 0x77, 0x32, 0xEA, 0x63, 0xB0, 0x2B, 0x4F, 0xA0, 0xF4,
	    0x87, 0x33, 0x60, 0xE2, 0x84, 0x19, 0x28, 0xCD, 0x60, 0xDD, 0x4C, 0xEE, 0x8C, 0xC0, 0xD4, 0xC9,
	    0x22, 0xA9, 0x61, 0x88, 0xD0, 0x32, 0x67, 0x5C, 0x8A, 0xC8, 0x50, 0x93, 0x3C, 0x7A, 0xFF, 0x15,
	    0x33, 0xB9, 0x4C, 0x83, 0x4A, 0xDB, 0xB6, 0x9C, 0x61, 0x15, 0xBA, 0xD4, 0x69, 0x2D, 0x86, 0x19,
	    0xF9, 0x0B, 0x0C, 0xDF, 0x8A, 0x7B, 0x9C, 0x26, 0x40, 0x29, 0xAC, 0x18, 0x5B, 0x70, 0xB8, 0x3F,
	    0x28, 0x01, 0xF2, 0xF4, 0xB3, 0xF7, 0x0C, 0x59, 0x3E, 0xA3, 0xAE, 0xEB, 0x61, 0x3A, 0x7F, 0x1B,
	    0x1D, 0xE3, 0x3F, 0xD7, 0x50, 0x81, 0xF5, 0x92, 0x30, 0x5F, 0x2E, 0x45, 0x26, 0xED, 0xC0, 0x96,
	    0x31, 0xB1, 0x09, 0x58, 0xF4, 0x64, 0xD8, 0x89, 0xF3, 0x1B, 0xA0, 0x10, 0x25, 0x0F, 0xDA, 0x7F,
	    0x13, 0x68, 0xEC, 0x29, 0x67, 0xFC, 0x84, 0xEF, 0x2A, 0xE9, 0xAF, 0xF2, 0x68, 0xE0, 0xB1, 0x70,
	    0x0A, 0xFF, 0xC6, 0x82, 0x0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xB8, 0xD2, 0xB5, 0x94, 0x94, 0x6B, 0x9C, 0x81, 0x33, 0x3F, 0x9B, 0xB6, 0xE0, 0xCE,
	    0x75, 0xC3, 0xB9, 0x31, 0x04, 0xFA, 0x34, 0x69, 0xD3, 0x91, 0x74, 0x57, 0x38, 0x5D, 0xA0, 0x37,
	    0xCF, 0x23, 0x2E, 0xF7, 0x16, 0x4A, 0x6D, 0x1E, 0xB4, 0x48, 0xC8, 0x90, 0x81, 0x86, 0xAD, 0x85,
	    0x2D, 0x3F, 0x85, 0xA5, 0xCF, 0x28, 0xDA, 0x1A, 0xB6, 0xFE, 0x34, 0x38, 0x17, 0x19, 0x78, 0x46,
	    0x7F, 0x1C, 0x05, 0xD5, 0x8C, 0x7E, 0xF3, 0x8C, 0x28, 0x4C, 0x41, 0xF6, 0xC2, 0x22, 0x1A, 0x76,
	    0xF1, 0x2A, 0xB1, 0xC0, 0x40, 0x82, 0x66, 0x02, 0x50, 0x80, 0x22, 0x94, 0xFB, 0x87, 0x18, 0x02,
	    0x13, 0xFD, 0xEF, 0x5B, 0x0E, 0xCB, 0x7D, 0xF5, 0x0C, 0xA1, 0xF8, 0x55, 0x5B, 0xE1, 0x4D, 0x32,
	    0xE1, 0x0F, 0x6E, 0xDC, 0xDE, 0x89, 0x2C, 0x09, 0x42, 0x4B, 0x29, 0xF5, 0x97, 0xAF, 0xC2, 0x70,
	    0xC9, 0x04, 0x55, 0x6B, 0xFC, 0xB4, 0x7A, 0x7D, 0x40, 0x77, 0x8D, 0x39, 0x09, 0x23, 0x64, 0x2B,
	    0x3C, 0xBD, 0x05, 0x79, 0xE6, 0x09, 0x08, 0xD5, 0xA0, 0x00, 0xC1, 0xD0, 0x8B, 0x98, 0xEF, 0x93,
	    0x3F, 0x80, 0x64, 0x45, 0xBF, 0x87, 0xF8, 0xB0, 0x09, 0xBA, 0x9E, 0x94, 0xF7, 0x26, 0x61, 0x22,
	    0xED, 0x7A, 0xC2, 0x4E, 0x5E, 0x26, 0x6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0x5B, 0x08, 0x3B, 0xAC, 0x45, 0xA8, 0xE5, 0xE9,
	    0xB7, 0x44, 0xC8, 0x50, 0x6F, 0x37, 0xE9, 0xB4, 0xE7, 0x49, 0xA1, 0x84, 0xB3, 0x0F, 0x43, 0xEB,
	    0x18, 0x8D, 0x85, 0x5F, 0x1B, 0x70, 0xD7, 0x1F, 0xF3, 0xE5, 0x0C, 0x53, 0x7A, 0xC1, 0xB0, 0xF8,
	    0x97, 0x4F, 0x0F, 0xE1, 0xA6, 0xAD, 0x29, 0x5B, 0xA4, 0x2F, 0x6A, 0xEC, 0x74, 0xD1, 0x23, 0xA7,
	    0xAB, 0xED, 0xDE, 0x6E, 0x2C, 0x07, 0x11, 0xCA, 0xB3, 0x6B, 0xE5, 0xAC, 0xB1, 0xA5, 0xA1, 0x1A,
	    0x4B, 0x1D, 0xB0, 0x8B, 0xA6, 0x98, 0x2E, 0xFC, 0xCD, 0x71, 0x69, 0x29, 0xA7, 0x74, 0x1C, 0xFC,
	    0x63, 0xAA, 0x44, 0x35, 0xE0, 0xB6, 0x9A, 0x90, 0x63, 0xE8, 0x80, 0x79, 0x5C, 0x3D, 0xC5, 0xEF,
	    0x32, 0x72, 0xE1, 0x1C, 0x49, 0x7A, 0x91, 0xAC, 0xF6, 0x99, 0xFE, 0xFE, 0xE2, 0x06, 0x22, 0x7A,
	    0x44, 0xC9, 0xFB, 0x35, 0x9F, 0xD5, 0x6A, 0xC0, 0xA9, 0xA7, 0x5A, 0x74, 0x3C, 0xFF, 0x68, 0x62,
	    0xF1, 0x7D, 0x72, 0x59, 0xAB, 0x07, 0x52, 0x16, 0xC0, 0x69, 0x95, 0x11, 0x64, 0x3B, 0x64, 0x39};

	/* test compact api */

	clear8(output, 512);
	OQS_SHA3_shake128(output, 512, msg0, 0);

	if (are_equal8(output, exp0, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 512);
	OQS_SHA3_shake128(output, 512, msg1600, 200);

	if (are_equal8(output, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	/* test long-form api */

	uint64_t state[25];
	uint8_t hash[OQS_SHA3_SHAKE128_RATE * 4];

	clear8(hash, OQS_SHA3_SHAKE128_RATE * 4);
	clear64(state, 25);
	OQS_SHA3_shake128_absorb(state, msg1600, 200);
	OQS_SHA3_shake128_squeezeblocks(hash, 4, state);

	if (are_equal8(hash, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	return status;
}

/**
* \brief Tests the 256 bit version of the SHAKE XOF function for correct operation,
* using selected vectors from the NIST reference package.
*
* \return Returns 1 for success, 0 for failure
*
* \remarks <b>Test References:</b> \n
* SP800-185: <a href="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf">SHA-3 Derived Functions</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHAKE256_Msg0.pdf">SHAKE256(0)</a> \n
* KAT: <a href="https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHAKE256_Msg1600.pdf">SHAKE256(1600)</a>
*/
int shake_256_kat_test() {
	int status = SHA3_STATUS_SUCCESS;

	uint8_t output[512];

	uint8_t msg0[1] = {0x0};
	uint8_t msg1600[200] = {
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3,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x3F, 0xCD, 0x52, 0xEA, 0x62, 0xB8, 0x1B, 0x82, 0xB5, 0x0C, 0x27, 0x64, 0x6E, 0xD5, 0x76, 0x2F,
	    0xD7, 0x5D, 0xC4, 0xDD, 0xD8, 0xC0, 0xF2, 0x00, 0xCB, 0x05, 0x01, 0x9D, 0x67, 0xB5, 0x92, 0xF6,
	    0xFC, 0x82, 0x1C, 0x49, 0x47, 0x9A, 0xB4, 0x86, 0x40, 0x29, 0x2E, 0xAC, 0xB3, 0xB7, 0xC4, 0xBE,
	    0x14, 0x1E, 0x96, 0x61, 0x6F, 0xB1, 0x39, 0x57, 0x69, 0x2C, 0xC7, 0xED, 0xD0, 0xB4, 0x5A, 0xE3,
	    0xDC, 0x07, 0x22, 0x3C, 0x8E, 0x92, 0x93, 0x7B, 0xEF, 0x84, 0xBC, 0x0E, 0xAB, 0x86, 0x28, 0x53,
	    0x34, 0x9E, 0xC7, 0x55, 0x46, 0xF5, 0x8F, 0xB7, 0xC2, 0x77, 0x5C, 0x38, 0x46, 0x2C, 0x50, 0x10,
	    0xD8, 0x46, 0xC1, 0x85, 0xC1, 0x51, 0x11, 0xE5, 0x95, 0x52, 0x2A, 0x6B, 0xCD, 0x16, 0xCF, 0x86,
	    0xF3, 0xD1, 0x22, 0x10, 0x9E, 0x3B, 0x1F, 0xDD, 0x94, 0x3B, 0x6A, 0xEC, 0x46, 0x8A, 0x2D, 0x62,
	    0x1A, 0x7C, 0x06, 0xC6, 0xA9, 0x57, 0xC6, 0x2B, 0x54, 0xDA, 0xFC, 0x3B, 0xE8, 0x75, 0x67, 0xD6,
	    0x77, 0x23, 0x13, 0x95, 0xF6, 0x14, 0x72, 0x93, 0xB6, 0x8C, 0xEA, 0xB7, 0xA9, 0xE0, 0xC5, 0x8D,
	    0x86, 0x4E, 0x8E, 0xFD, 0xE4, 0xE1, 0xB9, 0xA4, 0x6C, 0xBE, 0x85, 0x47, 0x13, 0x67, 0x2F, 0x5C,
	    0xAA, 0xAE, 0x31, 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F, 0x72, 0x9E, 0xC6, 0xCF, 0xA3, 0x6C, 0x6A, 0xC6, 0xA7, 0x58, 0x37,
	    0x14, 0x30, 0x45, 0xD7, 0x91, 0xCC, 0x85, 0xEF, 0xF5, 0xB2, 0x19, 0x32, 0xF2, 0x38, 0x61, 0xBC,
	    0xF2, 0x3A, 0x52, 0xB5, 0xDA, 0x67, 0xEA, 0xF7, 0xBA, 0xAE, 0x0F, 0x5F, 0xB1, 0x36, 0x9D, 0xB7,
	    0x8F, 0x3A, 0xC4, 0x5F, 0x8C, 0x4A, 0xC5, 0x67, 0x1D, 0x85, 0x73, 0x5C, 0xDD, 0xDB, 0x09, 0xD2,
	    0xB1, 0xE3, 0x4A, 0x1F, 0xC0, 0x66, 0xFF, 0x4A, 0x16, 0x2C, 0xB2, 0x63, 0xD6, 0x54, 0x12, 0x74,
	    0xAE, 0x2F, 0xCC, 0x86, 0x5F, 0x61, 0x8A, 0xBE, 0x27, 0xC1, 0x24, 0xCD, 0x8B, 0x07, 0x4C, 0xCD,
	    0x51, 0x63, 0x01, 0xB9, 0x18, 0x75, 0x82, 0x4D, 0x09, 0x95, 0x8F, 0x34, 0x1E, 0xF2, 0x74, 0xBD,
	    0xAB, 0x0B, 0xAE, 0x31, 0x63, 0x39, 0x89, 0x43, 0x04, 0xE3, 0x58, 0x77, 0xB0, 0xC2, 0x8A, 0x9B,
	    0x1F, 0xD1, 0x66, 0xC7, 0x96, 0xB9, 0xCC, 0x25, 0x8A, 0x06, 0x4A, 0x8F, 0x57, 0xE2, 0x7F, 0x2A};
	uint8_t exp1600[512] = {
	    0xCD, 0x8A, 0x92, 0x0E, 0xD1, 0x41, 0xAA, 0x04, 0x07, 0xA2, 0x2D, 0x59, 0x28, 0x86, 0x52, 0xE9,
	    0xD9, 0xF1, 0xA7, 0xEE, 0x0C, 0x1E, 0x7C, 0x1C, 0xA6, 0x99, 0x42, 0x4D, 0xA8, 0x4A, 0x90, 0x4D,
	    0x2D, 0x70, 0x0C, 0xAA, 0xE7, 0x39, 0x6E, 0xCE, 0x96, 0x60, 0x44, 0x40, 0x57, 0x7D, 0xA4, 0xF3,
	    0xAA, 0x22, 0xAE, 0xB8, 0x85, 0x7F, 0x96, 0x1C, 0x4C, 0xD8, 0xE0, 0x6F, 0x0A, 0xE6, 0x61, 0x0B,
	    0x10, 0x48, 0xA7, 0xF6, 0x4E, 0x10, 0x74, 0xCD, 0x62, 0x9E, 0x85, 0xAD, 0x75, 0x66, 0x04, 0x8E,
	    0xFC, 0x4F, 0xB5, 0x00, 0xB4, 0x86, 0xA3, 0x30, 0x9A, 0x8F, 0x26, 0x72, 0x4C, 0x0E, 0xD6, 0x28,
	    0x00, 0x1A, 0x10, 0x99, 0x42, 0x24, 0x68, 0xDE, 0x72, 0x6F, 0x10, 0x61, 0xD9, 0x9E, 0xB9, 0xE9,
	    0x36, 0x04, 0xD5, 0xAA, 0x74, 0x67, 0xD4, 0xB1, 0xBD, 0x64, 0x84, 0x58, 0x2A, 0x38, 0x43, 0x17,
	    0xD7, 0xF4, 0x7D, 0x75, 0x0B, 0x8F, 0x54, 0x99, 0x51, 0x2B, 0xB8, 0x5A, 0x22, 0x6C, 0x42, 0x43,
	    0x55, 0x6E, 0x69, 0x6F, 0x6B, 0xD0, 0x72, 0xC5, 0xAA, 0x2D, 0x9B, 0x69, 0x73, 0x02, 0x44, 0xB5,
	    0x68, 0x53, 0xD1, 0x69, 0x70, 0xAD, 0x81, 0x7E, 0x21, 0x3E, 0x47, 0x06, 0x18, 0x17, 0x80, 0x01,
	    0xC9, 0xFB, 0x56, 0xC5, 0x4F, 0xEF, 0xA5, 0xFE, 0xE6, 0x7D, 0x2D, 0xA5, 0x24, 0xBB, 0x3B, 0x0B,
	    0x61, 0xEF, 0x0E, 0x91, 0x14, 0xA9, 0x2C, 0xDB, 0xB6, 0xCC, 0xCB, 0x98, 0x61, 0x5C, 0xFE, 0x76,
	    0xE3, 0x51, 0x0D, 0xD8, 0x8D, 0x1C, 0xC2, 0x8F,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0xEC, 0x48, 0xC1, 0xC7, 0x16, 0x45,
	    0x86, 0xEA, 0xE0, 0x6A, 0x51, 0x20, 0x8C, 0x0B, 0x79, 0x12, 0x44, 0xD3, 0x07, 0x72, 0x65, 0x05,
	    0xC3, 0xAD, 0x4B, 0x26, 0xB6, 0x82, 0x23, 0x77, 0x25, 0x7A, 0xA1, 0x52, 0x03, 0x75, 0x60, 0xA7,
	    0x39, 0x71, 0x4A, 0x3C, 0xA7, 0x9B, 0xD6, 0x05, 0x54, 0x7C, 0x9B, 0x78, 0xDD, 0x1F, 0x59, 0x6F,
	    0x2D, 0x4F, 0x17, 0x91, 0xBC, 0x68, 0x9A, 0x0E, 0x9B, 0x79, 0x9A, 0x37, 0x33, 0x9C, 0x04, 0x27,
	    0x57, 0x33, 0x74, 0x01, 0x43, 0xEF, 0x5D, 0x2B, 0x58, 0xB9, 0x6A, 0x36, 0x3D, 0x4E, 0x08, 0x07,
	    0x6A, 0x1A, 0x9D, 0x78, 0x46, 0x43, 0x6E, 0x4D, 0xCA, 0x57, 0x28, 0xB6, 0xF7, 0x60, 0xEE, 0xF0,
	    0xCA, 0x92, 0xBF, 0x0B, 0xE5, 0x61, 0x5E, 0x96, 0x95, 0x9D, 0x76, 0x71, 0x97, 0xA0, 0xBE, 0xEB};

	/* test compact api */

	clear8(output, 512);
	OQS_SHA3_shake256(output, 512, msg0, 0);

	if (are_equal8(output, exp0, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 512);
	OQS_SHA3_shake256(output, 512, msg1600, 200);

	if (are_equal8(output, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	/* test long-form api */

	uint64_t state[25];
	uint8_t hash[OQS_SHA3_SHAKE256_RATE * 4];

	clear8(hash, OQS_SHA3_SHAKE256_RATE * 4);
	clear64(state, 25);
	OQS_SHA3_shake256_absorb(state, msg1600, 200);
	OQS_SHA3_shake256_squeezeblocks(hash, 4, state);

	if (are_equal8(hash, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	return status;
}

/**
* \brief Tests the 128 bit version of the simple cSHAKE function for correct operation,
* using vectors generated by a verified implementation.
*
* \return Returns 1 for success, 0 for failure
*
* \remarks <b>References:</b> \n
* Microsoft PQCrypto: <a href="https://github.com/Microsoft/PQCrypto-LWEKE/blob/master/src/sha3/fips202.c">fips202.c</a> \n
* SP800-185: <a href="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf">SHA-3 Derived Functions</a>
*/
int cshake_simple_128_kat_test() {
	int status = SHA3_STATUS_SUCCESS;

	uint8_t output[512];

	uint8_t msg0[1] = {0x0};
	uint8_t msg1600[200] = {
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 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0xDF, 0x2D, 0xD4, 0x10, 0x16, 0x12, 0x84, 0x8E, 0x1F,
	    0xD7, 0x57, 0xB9, 0x68, 0x46, 0xFB, 0x96, 0xE0, 0xEA, 0x36, 0x3A, 0xB0, 0x17, 0x00, 0x71, 0x19,
	    0x0A, 0x6E, 0xB7, 0x02, 0xF9, 0x71, 0xE4, 0xF9, 0x05, 0x9E, 0xE5, 0xBD, 0x74, 0x54, 0x88, 0x97,
	    0x2F, 0xE1, 0x51, 0x32, 0x28, 0x84, 0x5A, 0x60, 0x1B, 0xFA, 0x1C, 0x63, 0x11, 0x2B, 0xDF, 0x63,
	    0xF0, 0xC2, 0x4C, 0x7F, 0x1B, 0xCA, 0xE2, 0x9A, 0xB2, 0x18, 0x9F, 0xCC, 0x37, 0x96, 0x57, 0x41,
	    0x7B, 0x1A, 0x40, 0x48, 0xE9, 0x50, 0xB9, 0x71, 0xBC, 0x8E, 0x3F, 0x91, 0xF4, 0x47, 0xC1, 0x96,
	    0xA6, 0xB1, 0xDC, 0xFA, 0x74, 0xEF, 0xB4, 0xB6, 0x3A, 0x53, 0x46, 0xEE, 0xFD, 0xAA, 0x55, 0x41,
	    0x77, 0xCD, 0xE1, 0x63, 0xFC, 0x48, 0xEE, 0x61, 0x19, 0x0F, 0xAB, 0x43, 0xBC, 0xD2, 0xB7, 0xD3,
	    0x18, 0xC5, 0xE7, 0x96, 0x64, 0xD8, 0xEC, 0x07, 0xFD, 0x2F, 0xB6, 0x2E, 0x35, 0xD1, 0x51, 0x2E,
	    0x3B, 0xCC, 0x1B, 0xBA, 0xCC, 0x9E, 0xAB, 0x72, 0xB8, 0x2F, 0x6A, 0xB2, 0xF5, 0x1C, 0xDB, 0x7C,
	    0xF7, 0x38, 0xF6, 0x3E, 0xBE, 0xE1, 0x93, 0x22, 0xAE, 0x1D, 0xB9, 0x3F, 0x71, 0x69, 0xA1, 0xEF,
	    0x68, 0x91, 0x04, 0xDD, 0x4D, 0xBB, 0x82, 0x74, 0x83, 0x27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0xB4, 0xC9, 0xCF, 0xF4,
	    0xF9, 0x98, 0x5F, 0x17, 0x59, 0x67, 0x07, 0x58, 0xD5, 0xA7, 0x9A, 0xD5, 0x58, 0x3B, 0xDA, 0xF7,
	    0x16, 0x5F, 0xFB, 0xA8, 0x7F, 0x98, 0xFE, 0x55, 0x92, 0x35, 0x2E, 0x97, 0x18, 0x5C, 0xA4, 0x46,
	    0xE3, 0x10, 0x95, 0x11, 0x80, 0x8A, 0x9E, 0x46, 0x2D, 0xD0, 0xAA, 0xCF, 0x28, 0x62, 0x4B, 0x6D,
	    0x76, 0xBE, 0x60, 0xC1, 0x91, 0x32, 0xF4, 0xFF, 0xAA, 0xD3, 0x04, 0xFD, 0x36, 0x47, 0xA6, 0x47,
	    0x42, 0xF3, 0x61, 0xE4, 0xE9, 0x4E, 0xFA, 0xA9, 0x57, 0x1C, 0x51, 0xB6, 0x76, 0xD2, 0x31, 0x98};
	uint8_t exp1600[512] = {
	    0x6B, 0x91, 0x4E, 0x9D, 0x71, 0x6F, 0x1C, 0xD4, 0x7B, 0x83, 0xCC, 0xF4, 0x91, 0x56, 0x5D, 0xD2,
	    0xBF, 0x68, 0x60, 0xC4, 0xCF, 0x33, 0xA4, 0xCB, 0xB2, 0x8D, 0x44, 0xDB, 0x6C, 0xBF, 0xF7, 0x03,
	    0xA7, 0xC5, 0x67, 0x00, 0xBB, 0x66, 0x0F, 0xCC, 0xF8, 0x49, 0x6F, 0x7C, 0x52, 0xBE, 0x95, 0x95,
	    0x96, 0x8E, 0xD4, 0xE5, 0x71, 0x09, 0x15, 0xF3, 0x3A, 0xFA, 0x1E, 0x52, 0x16, 0x4F, 0x96, 0x66,
	    0x3C, 0x79, 0x7D, 0xA1, 0xDF, 0xA5, 0xE7, 0xE0, 0x28, 0x06, 0x47, 0x50, 0x42, 0xB7, 0xA4, 0xA2,
	    0x25, 0xCD, 0x70, 0xEE, 0x8B, 0xDB, 0xA8, 0xB7, 0xC2, 0x81, 0x60, 0x89, 0x7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0x78,
	    0x4B, 0x63, 0xCB, 0x15, 0x06, 0x75, 0x9B, 0x9B, 0xCE, 0xA0, 0x06, 0x4F, 0x41, 0xFB, 0x93, 0x3B,
	    0xD8, 0x59, 0xFA, 0xAC, 0xCE, 0xF2, 0xB3, 0xFB, 0x10, 0x42, 0x54, 0x4B, 0x4B, 0x2C, 0xA2, 0xF7,
	    0xC2, 0xE9, 0xCA, 0xF1, 0x1B, 0xC6, 0x85, 0xF5, 0x58, 0xCD, 0x5C, 0x32, 0x4C, 0x7F, 0xFD, 0xAE,
	    0x88, 0x12, 0x73, 0x07, 0x41, 0xBA, 0xD2, 0xEF, 0xBC, 0x32, 0x68, 0xDC, 0xC7, 0x74, 0x81, 0x25};

	/* test compact api */

	clear8(output, 512);
	OQS_SHA3_cshake128_simple(output, 512, 1, msg0, 0);

	if (are_equal8(output, exp0, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 512);
	OQS_SHA3_cshake128_simple(output, 512, 1, msg1600, 200);

	if (are_equal8(output, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	/* test long-form api */

	uint64_t state[25];
	uint8_t hash[OQS_SHA3_CSHAKE128_RATE * 4];

	clear8(hash, OQS_SHA3_CSHAKE128_RATE * 4);
	clear64(state, 25);
	OQS_SHA3_cshake128_simple_absorb(state, 1, msg1600, 200);
	OQS_SHA3_cshake128_simple_squeezeblocks(hash, 4, state);

	if (are_equal8(hash, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	return status;
}

/**
* \brief Tests the 256 bit version of the simple cSHAKE function for correct operation,
* using vectors generated by a verified implementation.
*
* \return Returns 1 for success, 0 for failure
*
* \remarks <b>References:</b> \n
* Microsoft PQCrypto: <a href="https://github.com/Microsoft/PQCrypto-LWEKE/blob/master/src/sha3/fips202.c">fips202.c</a> \n
* SP800-185: <a href="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf">SHA-3 Derived Functions</a>
*/
int cshake_simple_256_kat_test() {
	int status = SHA3_STATUS_SUCCESS;

	uint8_t output[512];

	uint8_t msg0[1] = {0x0};
	uint8_t msg1600[200] = {
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
	    0xA3, 0xA3, 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xAB, 0x06, 0x2D, 0x88, 0xB6, 0xC8, 0x46, 0x08, 0x82,
	    0x5F, 0xB1, 0x94, 0x30, 0x98, 0x6B, 0x94, 0x3A, 0x27, 0x12, 0x02, 0xA9, 0x84, 0x48, 0x59, 0xAC,
	    0x10, 0x02, 0xF2, 0x59, 0x28, 0x44, 0x9F, 0xB7, 0x6D, 0x09, 0xBC, 0x3C, 0xE4, 0x79, 0x21, 0x51,
	    0xD3, 0x2E, 0xBF, 0xAF, 0x53, 0x84, 0x6D, 0x29, 0xA4, 0x17, 0x34, 0x06, 0x49, 0x4B, 0x1C, 0x72,
	    0x99, 0xCA, 0x01, 0xF8, 0x20, 0x3F, 0x47, 0x57, 0x20, 0xC5, 0xEC, 0x8B, 0x02, 0x5B, 0xBC, 0xEF,
	    0xAF, 0xEE, 0xF4, 0xF9, 0x78, 0x03, 0x92, 0x7B, 0xEC, 0x6C, 0x05, 0x0C, 0xCC, 0xE5, 0xE3, 0x9E,
	    0x33, 0x9B, 0x72, 0x07, 0xF6, 0x76, 0x98, 0xBD, 0x78, 0x62, 0x98, 0x62, 0x97, 0x57, 0x7C, 0xC4,
	    0xD9, 0x1F, 0x9F, 0x17, 0xBD, 0xD9, 0x0E, 0x7F, 0xBD, 0x5D, 0x93, 0x72, 0x31, 0xBB, 0x51, 0xAF,
	    0x25, 0xC7, 0x1B, 0x11, 0x83, 0xD4, 0x38, 0x92, 0x26, 0xAE, 0x61, 0xB8, 0x3B, 0x58, 0xF7, 0xD6,
	    0x63, 0x20, 0xAC, 0x4C, 0x9B, 0xFF, 0x52, 0x28, 0x55, 0xE9, 0xA5, 0x5A, 0x15, 0x10, 0xA2, 0xB8,
	    0xCA, 0x7F, 0x11, 0x24, 0x65, 0x6A, 0x2B, 0xAA, 0xDC, 0xEF, 0xCD, 0x6B, 0xBC, 0x0D, 0xAE, 0xF4,
	    0x14, 0x03, 0x7B, 0xC8, 0x04, 0x32, 0x5D, 0x5D, 0x81, 0x55, 0x81, 0x26, 0xBA, 0xE9, 0x90, 0x5B,
	    0x4C, 0xAB, 0x03, 0x79, 0x3B, 0xCD, 0xCB, 0x44, 0xA4, 0x16, 0x7B, 0xE8, 0x23, 0x7E, 0x31, 0x6C,
	    0x73, 0x9B, 0x06, 0x76, 0x02, 0xC1, 0x23, 0xA8, 0xF7, 0xF0, 0x0E, 0x85, 0xA5, 0x6D, 0x5E, 0x76,
	    0x3D, 0x08, 0x0C, 0x81, 0xBB, 0xBA, 0x18, 0x78, 0xA0, 0xE7, 0xBA, 0x6C, 0x45, 0x21, 0x2F, 0xC0,
	    0x55, 0x66, 0x22, 0x0F, 0x87, 0xCA, 0xDA, 0x00, 0xCB, 0xFC, 0xD4, 0xAB, 0x64, 0x4D, 0x45, 0x6B,
	    0xC6, 0x80, 0xB3, 0xDA, 0xEE, 0x29, 0xA9, 0x93, 0xA6, 0xA0, 0xE2, 0x04, 0x45, 0x56, 0x25, 0xC3,
	    0x91, 0x26, 0xE7, 0x07, 0x39, 0x54, 0x91, 0x21, 0x92, 0xF9, 0x62, 0x7D, 0x1C, 0xFF, 0x21, 0x74,
	    0x6F, 0x5C, 0x44, 0x6B, 0xDC, 0x8D, 0xED, 0x31, 0x41, 0x6D, 0xEA, 0x04, 0x6C, 0xD1, 0x6F, 0x03,
	    0xA8, 0x12, 0x75, 0x7F, 0x16, 0x65, 0x9F, 0x7C, 0x2A, 0xF2, 0x74, 0x4B, 0x5F, 0x50, 0x85, 0xF0,
	    0x8A, 0x17, 0x3F, 0xBB, 0x1B, 0x50, 0x3F, 0x64, 0x7E, 0x4F, 0x33, 0x2F, 0x77, 0x7C, 0x37, 0xFB,
	    0x98, 0xFD, 0xC3, 0x7E, 0x73, 0x5D, 0xFD, 0x77, 0x1C, 0x45, 0x78, 0x01, 0x7A, 0x15, 0x55, 0xBF,
	    0x01, 0x78, 0xB8, 0xEE, 0xD1, 0xFB, 0x35, 0x7A, 0x38, 0xBE, 0xFF, 0x44, 0xA7, 0x53, 0xE2, 0x17,
	    0x8C, 0x22, 0x10, 0xAF, 0x88, 0x58, 0x78, 0x0C, 0xE0, 0x45, 0xEE, 0x6F, 0xBA, 0x8D, 0xF7, 0x99,
	    0x26, 0x99, 0x1B, 0xE1, 0x2D, 0x9E, 0x39, 0x53, 0x6D, 0x90, 0x91, 0x25, 0x4E, 0x1D, 0xF7, 0x81,
	};
	uint8_t exp1600[512] = {
	    0xE5, 0x3E, 0x39, 0xA5, 0x84, 0x7B, 0x62, 0x8D, 0x4F, 0xBD, 0xF0, 0xA0, 0x84, 0x99, 0x08, 0x8D,
	    0xC0, 0xED, 0x96, 0x1C, 0x8E, 0x27, 0x9B, 0x0D, 0x67, 0xCE, 0x58, 0xDC, 0x69, 0xCE, 0xAA, 0xE5,
	    0x3C, 0x3A, 0x3B, 0xC9, 0xB1, 0x80, 0x4B, 0x5A, 0x15, 0x63, 0x2F, 0x7C, 0xD7, 0x0A, 0x72, 0x55,
	    0x03, 0xAB, 0x0E, 0xA9, 0xC1, 0x57, 0x85, 0xD7, 0x06, 0x59, 0x7F, 0x93, 0x26, 0x96, 0x59, 0x38,
	    0x00, 0x0B, 0x30, 0xEB, 0x83, 0xAE, 0xB9, 0x88, 0x72, 0xC2, 0x28, 0xF5, 0xED, 0x5A, 0x14, 0x14,
	    0x41, 0x92, 0xAC, 0x32, 0xEF, 0xE1, 0x97, 0xF6, 0x16, 0x41, 0xE1, 0x99, 0xE8, 0xBC, 0x13, 0x96,
	    0xC2, 0x4D, 0xEF, 0x0A, 0x23, 0xDE, 0x97, 0x69, 0xF0, 0x68, 0xDA, 0xAF, 0x17, 0x77, 0x55, 0xC7,
	    0x51, 0xE2, 0x52, 0x4A, 0xF2, 0xDD, 0x9F, 0xB1, 0x23, 0x1A, 0xB7, 0xA6, 0xB6, 0xE9, 0xDE, 0xE6,
	    0x99, 0x3B, 0x52, 0x2C, 0x8A, 0x46, 0xCD, 0xAB, 0x83, 0x3D, 0xD9, 0x17, 0xBB, 0x1E, 0x57, 0xB9,
	    0x69,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B1, 0x2E, 0x64, 0x19, 0xF1, 0xCD, 0x80, 0x9B, 0xCB, 0xCC, 0x8D, 0x2A, 0x6F, 0x3A,
	    0xAC, 0xA4, 0xC2, 0x85, 0x0B, 0x68, 0x26, 0x85, 0xD2, 0xAB, 0xB1, 0x73, 0xEB, 0x67, 0xA4, 0x28,
	    0xEC, 0xDE, 0xAF, 0x8A, 0x6F, 0xA9, 0x09, 0x44, 0x24, 0x45, 0xE3, 0x89, 0xA6, 0x18, 0x0B, 0xE1,
	    0x5F, 0x6E, 0x95, 0x49, 0x43, 0xBC, 0xE0, 0x06, 0x3F, 0xB2, 0xFE, 0xD6, 0x2A, 0xC1, 0x83, 0x40,
	    0x0F, 0x42, 0x22, 0x30, 0x82, 0xFD, 0x7D, 0x3A, 0x5F, 0xE0, 0x34, 0x13, 0xF8, 0x02, 0xB2, 0x4D,
	    0x9E, 0xFB, 0x38, 0xE8, 0x07, 0xFD, 0x53, 0x46, 0x56, 0x49, 0xA8, 0x25, 0x97, 0xAB, 0x60, 0x06,
	    0xD5, 0xB6, 0x1F, 0x0F, 0x73, 0x26, 0x6B, 0x8B, 0xD6, 0x46, 0x39, 0x33, 0x14, 0x93, 0x53, 0xFA,
	    0xF3, 0x55, 0xAE, 0x23, 0x17, 0x8C, 0xD4, 0x71, 0xF6, 0x65, 0x51, 0x42, 0x15, 0xA0, 0xE5, 0x1E,
	    0xF4, 0x73, 0x34, 0xEB, 0x43, 0x19, 0xE5, 0xA7, 0x31, 0x62, 0xFD, 0x48, 0x92, 0xFB, 0xF2, 0x02,
	    0x60, 0x2B, 0x2A, 0xFD, 0xDE, 0xF2, 0x17, 0xD4, 0xAD, 0x4D, 0xF5, 0x74, 0x05, 0x2B, 0xE3, 0x0A,
	    0x96, 0xCD, 0xF5, 0x21, 0x2B, 0x3B, 0x69, 0x7C, 0x33, 0x21, 0x96, 0x48, 0x7A, 0xAA, 0x24, 0x33,
	    0xF7, 0x2D, 0x2B, 0x8E, 0xA0, 0x18, 0xE9, 0xDB, 0xC9, 0x65, 0x8D, 0x8B, 0x65, 0x98, 0x48, 0xE8};

	/* test compact api */

	clear8(output, 512);
	OQS_SHA3_cshake256_simple(output, 512, 1, msg0, 0);

	if (are_equal8(output, exp0, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	clear8(output, 512);
	OQS_SHA3_cshake256_simple(output, 512, 1, msg1600, 200);

	if (are_equal8(output, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	/* test long-form api */

	uint64_t state[25];
	uint8_t hash[OQS_SHA3_CSHAKE256_RATE * 4];

	clear8(hash, OQS_SHA3_CSHAKE256_RATE * 4);
	clear64(state, 25);
	OQS_SHA3_cshake256_simple_absorb(state, 1, msg1600, 200);
	OQS_SHA3_cshake256_simple_squeezeblocks(hash, 4, state);

	if (are_equal8(hash, exp1600, 512) == SHA3_STATUS_FAILURE) {
		status = SHA3_STATUS_FAILURE;
	}

	return status;
}

/**
* \brief Run the SHA3, SHAKE, and simple cSHAKE KAT tests
*/
int main(UNUSED int argc, UNUSED char **argv) {
	int ret = 0;
	if (sha3_256_kat_test() == SHA3_STATUS_SUCCESS) {
		printf("Success! passed sha3-256 known answer tests \n");
	} else {
		printf("Failure! failed sha3-256 known answer tests \n");
		ret = -1;
	}

	if (sha3_512_kat_test() == SHA3_STATUS_SUCCESS) {
		printf("Success! passed sha3-512 known answer tests \n");
	} else {
		printf("Failure! failed sha3-512 known answer tests \n");
		ret = -1;
	}

	if (shake_128_kat_test() == SHA3_STATUS_SUCCESS) {
		printf("Success! passed shake-128 known answer tests \n");
	} else {
		printf("Failure! failed shake-128 known answer tests \n");
		ret = -1;
	}

	if (shake_256_kat_test() == SHA3_STATUS_SUCCESS) {
		printf("Success! passed shake-256 known answer tests \n");
	} else {
		printf("Failure! failed shake-256 known answer tests \n");
		ret = -1;
	}

	if (cshake_simple_128_kat_test() == SHA3_STATUS_SUCCESS) {
		printf("Success! passed simple cshake-128 known answer tests \n");
	} else {
		printf("Failure! failed simple cshake-128 known answer tests \n");
		ret = -1;
	}

	if (cshake_simple_256_kat_test() == SHA3_STATUS_SUCCESS) {
		printf("Success! passed simple cshake-256 simple known answer tests \n");
	} else {
		printf("Failure! failed simple cshake-256 simple known answer tests \n");
		ret = -1;
	}
	return ret;
}
